#!/usr/bin/env python3
# This file a part of SHM. Copyright (C) Tom Li 2013.
# License: LGPL version 3 or later.


def create_alias(username, domain):
    domain_config = Config(CONFIG, username)
    domain_list = domain_config.domain
    domain_list.append(domain)
    domain = domain_list[0]
    domain_list_str = " ".join(domain_list)

    config_name = "/etc/nginx/sites-available/%s.conf" % domain
    user_group = "%s:%s" % (username, username)

    os.system("./nginx_conf %s %s > %s" % (username, domain_list, config_name))
    chown("%s:%s" % (username, username), config_name)
    
    domain_config.append_domain(domain)
